﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.LogEntries.ChangeRomanticStateLogEntry
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using Helpers;
using System.Collections.Generic;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.LogEntries
{
  public class ChangeRomanticStateLogEntry : LogEntry
  {
    [SaveableField(70)]
    public readonly Hero Hero1;
    [SaveableField(71)]
    public readonly Hero Hero2;
    [SaveableField(72)]
    public readonly Romance.RomanceLevelEnum Level;

    internal static void AutoGeneratedStaticCollectObjectsChangeRomanticStateLogEntry(
      object o,
      List<object> collectedObjects)
    {
      ((LogEntry) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      base.AutoGeneratedInstanceCollectObjects(collectedObjects);
      collectedObjects.Add((object) this.Hero1);
      collectedObjects.Add((object) this.Hero2);
    }

    internal static object AutoGeneratedGetMemberValueHero1(object o)
    {
      return (object) ((ChangeRomanticStateLogEntry) o).Hero1;
    }

    internal static object AutoGeneratedGetMemberValueHero2(object o)
    {
      return (object) ((ChangeRomanticStateLogEntry) o).Hero2;
    }

    internal static object AutoGeneratedGetMemberValueLevel(object o)
    {
      return (object) ((ChangeRomanticStateLogEntry) o).Level;
    }

    public ChangeRomanticStateLogEntry(Hero hero1, Hero hero2, Romance.RomanceLevelEnum level)
    {
      this.Hero1 = hero1;
      this.Hero2 = hero2;
      this.Level = level;
    }

    public override string ToString()
    {
      TextObject parent = new TextObject("{=!}Relation between {HERO_1.NAME} and {HERO_2.NAME} : {RELATION}");
      parent.SetTextVariable("RELATION", this.Level.ToString());
      StringHelpers.SetCharacterProperties("HERO_1", this.Hero1.CharacterObject, parent);
      StringHelpers.SetCharacterProperties("HERO_2", this.Hero2.CharacterObject, parent);
      return parent.ToString();
    }

    public override ImportanceEnum GetImportanceForClan(Clan clan)
    {
      if (this.Hero1.Clan != clan && this.Hero2.Clan != clan)
        return ImportanceEnum.Zero;
      return this.Level >= Romance.RomanceLevelEnum.CourtshipStarted ? ImportanceEnum.ExtremelyImportant : ImportanceEnum.Important;
    }

    public override void GetConversationScoreAndComment(
      Hero talkTroop,
      bool findString,
      out string comment,
      out ImportanceEnum score)
    {
      score = ImportanceEnum.Zero;
      comment = "";
      if (this.Hero1 != Hero.MainHero && this.Hero2 != Hero.MainHero)
        return;
      Hero person1 = this.Hero2;
      if (this.Hero2 == Hero.MainHero)
        person1 = this.Hero1;
      person1.SetTextVariables();
      if ((this.Hero1 == Hero.OneToOneConversationHero || this.Hero2 == Hero.OneToOneConversationHero) && this.Level == Romance.RomanceLevelEnum.MatchMadeByFamily)
      {
        score = ImportanceEnum.MatterOfLifeAndDeath;
        if (!findString)
          return;
        comment = "str_comment_changeromanticstate_match_made_by_family";
      }
      else if (this.Level >= Romance.RomanceLevelEnum.Marriage && person1 == Hero.OneToOneConversationHero)
      {
        score = ImportanceEnum.Important;
        if (!findString)
          return;
        comment = "str_comment_changeromanticstate_congratulations_marriage_self";
      }
      else if (this.Level >= Romance.RomanceLevelEnum.Marriage && person1 != Hero.OneToOneConversationHero && person1.MapFaction == Hero.OneToOneConversationHero.MapFaction && Hero.OneToOneConversationHero.IsLord)
      {
        score = ImportanceEnum.Important;
        if (!findString)
          return;
        comment = "str_comment_changeromanticstate_congratulations_marriage";
      }
      else if (Hero.OneToOneConversationHero.Spouse == person1 && this.Level >= Romance.RomanceLevelEnum.CourtshipStarted)
      {
        score = ImportanceEnum.MatterOfLifeAndDeath;
        if (!findString)
          return;
        comment = "str_comment_changeromanticstate_stay_away_from_my_spouse";
      }
      else
      {
        if (Romance.GetRomanticLevel(person1, Hero.OneToOneConversationHero) < Romance.RomanceLevelEnum.CourtshipStarted || this.Level < Romance.RomanceLevelEnum.CourtshipStarted)
          return;
        score = ImportanceEnum.MatterOfLifeAndDeath;
        if (!findString)
          return;
        comment = "str_comment_changeromanticstate_romantic_rival";
      }
    }
  }
}
